using UnityEngine;

public class BotTimerHard : BotHoleController
{
	private void Update()
	{
		if (!BaseGameManager.Instance.HasGameStarted || BaseGameManager.Instance._hasGameEnded)
		{
			return;
		}
		if ((bool)targetObject && targetObject.IsDestroyed)
		{
			target = null;
		}
		if ((bool)target)
		{
			if (!DestroyTargetIfOutOfBounds())
			{
				Vector3 vector = Vector3.MoveTowards(_cachedTransform.position, target.position, Time.deltaTime * _hole.Speed * _sensitivity);
				Vector3 position = _cachedTransform.position;
				vector.y = position.y;
				SetDirection(vector - _cachedTransform.position);
				_cachedTransform.position = vector;
				if (changeTargetTimer - Time.time < 0f)
				{
					target = null;
				}
			}
		}
		else
		{
			float value = Random.value;
			target = FindClosestTarget();
			if (target != null)
			{
				targetObject = target.GetComponent<FallingObjectBehaviour>();
				changeTargetTimer = Time.time + Random.Range(5f, 10f);
			}
		}
	}
}
